/**
 * @description 路由配置文件
*/

// const router = {
//   routes: [
//     {
//       path: '/ox/demo', // 示例
//       controller: DemoController,
//       children: [
//         {
//           path: 'list', // 示例列表
//           method: 'get',
//           action: 'queryAll'
//         }
//       ]
//     }
//   ]
// }
/* 自定义控制器 */
// 仅本地增、删、改
let permission = {
  // hosts: 'localhost',
  rules: ['admin']
}

const router = {
  routes: [
    {
      path: '/dblog', // 首页
      controller: require('../modules/index/controller.js'),
      children: [
        // 视图页面
        {
          path: 'index.html',
          method: 'get',
          action: 'index',
          type: 'PLAINHTML'
        },
        // 视图页面
        {
          path: 'index/index.html',
          method: 'get',
          action: 'index',
          type: 'PLAINHTML'
        }
      ]
    },
    {
      path: '/dblog/note', // 笔记
      controller: require('../modules/note/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            fields: [
              {field: 'id'},
              {field: 'title'},
              {field: 'type'},
              {field: 'cover'},
              {field: 'labels'},
              {field: 'orders'},
              {field: 'status'},
              {field: 'abstract'},
              {field: 'viewCount'},
              {field: 'createTime'},
              {field: 'updateTime'}
            ],
            
            operators: [
              {field: 'title', operator: 'LIKE'},
              {field: 'type', operator: 'EQUAL'},
              {field: 'labels', operator: 'LIKE'},
              {field: 'content', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            },
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'orders', by: 'desc'}
            ]
          }
        },
        {
          path: 'list/options',
          method: 'get',
          action: 'queryAll',
          excute: {
            fields: [
              {field: 'id'},
              {field: 'title'}
            ],
            operators: [
              {field: 'title', operator: 'LIKE'},
              {field: 'type', operator: 'EQUAL'},
              {field: 'labels', operator: 'LIKE'},
              {field: 'content', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'orders', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        },

        // 视图页面
        {
          path: 'v/index.html',
          method: 'get',
          action: 'index',
          type: 'PLAINHTML'
        },
        {
          path: 'v/detail.html',
          method: 'get',
          action: 'detail',
          type: 'PLAINHTML'
        },
        {
          path: 'v/api/list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            operators: [
              {field: 'title', operator: 'LIKE'},
              {field: 'type', operator: 'EQUAL'},
              {field: 'labels', operator: 'LIKE'},
              {field: 'content', operator: 'LIKE'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            }
          }
        }
      ]
    },
    {
      path: '/dblog/links', // 链接
      controller: require('../modules/links/controller.js'),
      children: [
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            operators: [
              {field: 'name', operator: 'LIKE'},
              {field: 'url', operator: 'LIKE'},
              {field: 'status', operator: 'EQUAL'},
              {field: 'createTime', operator: 'BETWEEN'},
              {field: 'updateTime', operator: 'BETWEEN'}
            ],
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'orders', by: 'desc'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            }
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'deleteAll',
          permission: permission
        }
      ]
    },
    {
      path: '/dblog/noteType', // 笔记类型
      controllerName: 'noteType',
      tableName: 'note_type',
      children: [
        {
          path: 'list',
          method: 'get',
          action: 'queryAll',
          excute: {
            sort: [
              {field: 'createTime', by: 'desc'},
              {field: 'orders', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query'
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'delete',
          permission: permission
        }
      ]
    },
    {
      path: '/dblog/dictionary', // 字典
      controllerName: 'dictionary',
      tableName: 'dictionary',
      children: [
        {
          path: 'list',
          method: 'get',
          action: 'queryAll',
          excute: {
            operators: [
              {field: 'cat', operator: 'EQUAL'},
              {field: 'code', operator: 'LIKE'},
              {field: 'key', operator: 'LIKE'},
              {field: 'value', operator: 'LIKE'},
              {field: 'description', operator: 'LIKE'},
              {field: 'remark', operator: 'LIKE'},
            ],
            sort: [
              {field: 'id', by: 'desc'},
              {field: 'cat', by: 'desc'},
              {field: 'code', by: 'desc'},
              {field: 'key', by: 'desc'},
              {field: 'value', by: 'desc'},
              {field: 'description', by: 'desc'},
              {field: 'remark', by: 'desc'},
              {field: 'dimension', by: 'desc'},
              {field: 'updateTime', by: 'desc'},
              {field: 'updateUser', by: 'desc'},
              {field: 'createTime', by: 'desc'},
              {field: 'createUser', by: 'desc'},
              {field: 'orders', by: 'desc'}
            ]
          }
        },
        {
          path: 'list/page',
          method: 'get',
          action: 'queryAllByPage',
          excute: {
            operators: [
              {field: 'id', operator: 'EQUAL'},
              {field: 'cat', operator: 'EQUAL'},
              {field: 'code', operator: 'EQUAL'},
              {field: 'key', operator: 'EQUAL'},
              {field: 'value', operator: 'LIKE'}
            ],
            limit: {
              pageSize: {field: 'pageSize', default: 10},
              pageIndex: {field: 'pageIndex', default: 1}
            },
            sort: [
              {field: 'id', by: 'desc'},
              {field: 'cat', by: 'desc'},
              {field: 'code', by: 'desc'},
              {field: 'key', by: 'desc'},
              {field: 'value', by: 'desc'},
              {field: 'description', by: 'desc'},
              {field: 'remark', by: 'desc'},
              {field: 'dimension', by: 'desc'},
              {field: 'updateTime', by: 'desc'},
              {field: 'updateUser', by: 'desc'},
              {field: 'createTime', by: 'desc'},
              {field: 'createUser', by: 'desc'},
              {field: 'orders', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'get',
          action: 'query',
          excute: {
            sort: [
              {field: 'id', by: 'desc'},
              {field: 'cat', by: 'desc'},
              {field: 'code', by: 'desc'},
              {field: 'key', by: 'desc'},
              {field: 'value', by: 'desc'},
              {field: 'description', by: 'desc'},
              {field: 'remark', by: 'desc'},
              {field: 'orders', by: 'desc'},
              {field: 'dimension', by: 'desc'},
              {field: 'updateTime', by: 'desc'},
              {field: 'updateUser', by: 'desc'},
              {field: 'createTime', by: 'desc'},
              {field: 'createUser', by: 'desc'}
            ]
          }
        },
        {
          path: 'item',
          method: 'put',
          action: 'add',
          permission: permission
        },
        {
          path: 'item',
          method: 'post',
          action: 'update',
          excute: {
            sort: [
              {field: 'id', by: 'desc'}
            ]
          },
          permission: permission
        },
        {
          path: 'item',
          method: 'delete',
          action: 'delete',
          excute: {
            sort: [
              {field: 'id', by: 'desc'}
            ]
          },
          permission: permission
        },
        {
          path: 'list/tree',
          method: 'get',
          action: 'queryTreeSub',
          excute: {
            sort: [
              {field: 'orders', by: 'desc'}
            ],
            treeLevel: 3
          }
        }
      ]
    },
    {
      path: '/dblog/user', // 用户页面
      controller: require('../modules/user/controller.js'),
      children: [
        {
          path: 'login',
          method: 'post',
          action: 'login'
        },
        {
          path: 'logout',
          method: 'post',
          action: 'logout'
        },
        {
          path: 'queryUserInfo',
          method: 'get',
          action: 'queryUserInfo'
        },
        // 视图页面
        {
          path: 'v/about.html',
          method: 'get',
          action: 'about',
          type: 'PLAINHTML'
        }
      ]
    }
  ]
}

module.exports = router